/* Copyright Statement:
 *
 * This software/firmware and related documentation ("MediaTek Software") are
 * protected under relevant copyright laws. The information contained herein is
 * confidential and proprietary to MediaTek Inc. and/or its licensors. Without
 * the prior written permission of MediaTek inc. and/or its licensors, any
 * reproduction, modification, use or disclosure of MediaTek Software, and
 * information contained herein, in whole or in part, shall be strictly
 * prohibited.
 *
 * MediaTek Inc. (C) 2010. All rights reserved.
 *
 * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
 * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
 * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
 * ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
 * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
 * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
 * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
 * INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
 * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
 * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
 * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
 * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
 * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
 * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
 * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
 * RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
 * MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
 * CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
 *
 * The following software/firmware and/or related documentation ("MediaTek
 * Software") have been modified by MediaTek Inc. All revisions are subject to
 * any receiver's applicable license agreements with MediaTek Inc.
 */

package com.mediatek.datatransfer;

import com.mediatek.datatransfer.utils.ModuleType;

/**
 * Describe class <code>RecordXmlInfo</code> here.
 *
 * @author
 * @version 1.0
 */
public class RecordXmlInfo {
    public static final String ROOT = "root";
    public static final String RESTORE = "restore";
    public static final String BACKUP = "backup";
    public static final String DEVICE = "device";
    public static final String TIME = "time";
    
    public static final String CONTACT = "contact";
    public static final String MESSAGE = "message";
    public static final String PICTURE = "picture";
    public static final String CALENDAR = "calendar";
    public static final String MUSIC = "music";
    public static final String BOOKMARK = "bookmark";
    public static final String NOTEBOOK = "notebook";
    
    private boolean mIsRestore;
    private String mDevice;
    private String mTime;
    
    private String mContact;
    private String mMessage;
    private String mPicture;
    private String mCalendar;
    private String mMusic;
    private String mBookmark;
    private String mNotebook;

    public RecordXmlInfo() {
    }

    public RecordXmlInfo(String device, String time, boolean isRestore) {
        setRestore(isRestore);
        setDevice(device);
        setTime(time);
    }

    public void setRecordXmlInfo(RecordXmlInfo oldInfo) {
        setmContact(oldInfo.getmContact());
        setmMessage(oldInfo.getmMessage());
        setmPicture(oldInfo.getmPicture());
        setmCalendar(oldInfo.getmCalendar());
        setmMusic(oldInfo.getmMusic());
        setmBookmark(oldInfo.getmBookmark());
        setmNotebook(oldInfo.getmNotebook());
    }
    
    public boolean isRestore() {
        return mIsRestore;
    }

    public void setRestore(boolean mIsRestore) {
        this.mIsRestore = mIsRestore;
    }

    public String getDevice() {
        return mDevice;
    }

    public void setDevice(String mDevice) {
        this.mDevice = mDevice;
    }

    public String getTime() {
        return mTime;
    }

    public void setTime(String mTime) {
        this.mTime = mTime;
    }

	public String getmContact() {
		return mContact;
	}

	public void setmContact(String mContact) {
		this.mContact = mContact;
	}

	public String getmMessage() {
		return mMessage;
	}

	public void setmMessage(String mMessage) {
		this.mMessage = mMessage;
	}

	public String getmPicture() {
		return mPicture;
	}

	public void setmPicture(String mPicture) {
		this.mPicture = mPicture;
	}

	public String getmCalendar() {
		return mCalendar;
	}

	public void setmCalendar(String mCalendar) {
		this.mCalendar = mCalendar;
	}

	public String getmMusic() {
		return mMusic;
	}

	public void setmMusic(String mMusic) {
		this.mMusic = mMusic;
	}

	public String getmBookmark() {
		return mBookmark;
	}

	public void setmBookmark(String mBookmark) {
		this.mBookmark = mBookmark;
	}

	public String getmNotebook() {
		return mNotebook;
	}

	public void setmNotebook(String mNotebook) {
		this.mNotebook = mNotebook;
	}
	
	private int stringParseInt(String str){
		if(str != null && !str.isEmpty()){
			return Integer.parseInt(str);
		} else {
			return -1;
		}
	}
	
	public int getCountByType(int type){
		int count = 0;
		switch (type) {
		case ModuleType.TYPE_CONTACT:
			count = stringParseInt(mContact);
            break;
        case ModuleType.TYPE_MESSAGE:
        	count = stringParseInt(mMessage);
            break;
        case ModuleType.TYPE_PICTURE:
        	count = stringParseInt(mPicture);
            break;
        case ModuleType.TYPE_CALENDAR:
        	count = stringParseInt(mCalendar);
            break;
        case ModuleType.TYPE_MUSIC:
        	count = stringParseInt(mMusic);
            break;
        case ModuleType.TYPE_NOTEBOOK:
        	count = stringParseInt(mNotebook);
            break;
        case ModuleType.TYPE_BOOKMARK:
        	count = stringParseInt(mBookmark);
            break;
        default:
            break;
		}
		return count;
	}
}
